import Vue from 'vue';
import VueRouter from 'vue-router';
import Home from '../views/Home.vue';
import Login from '../views/Login.vue';
import Welcome from '../views/Welcome.vue';
import DormAdminManager from '../views/DormAdminManager.vue';
import DormAdminAddOrEdit from '../views/DormAdminAddOrEdit.vue';
import StudentsManager from '../views/StudentsManager.vue';
import StudentsAddOrEdit from '../views/StudentsAddOrEdit.vue';
import DormsManager from '../views/DormsManager.vue';
import DormsAddOrEdit from '../views/DormsAddOrEdit.vue';
import AbsencesManager from '../views/AbsencesManager.vue';
import AbsencesAddOrEdit from '../views/AbsencesAddOrEdit.vue';
import ModifyPassword from '../views/ModifyPassword.vue';

Vue.use(VueRouter);

const routes = [
  {
    path: '/',//默认路径
    name: 'Login',
    component: Login
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    redirect: "/welcome.html",
    children: [
      {path: "/welcome.html", name: 'Welcome', component: Welcome},
      {path: "/dormAdmins.html", name: 'DormAdminManager', component: DormAdminManager},
      {path: "/dormAdmins/toAdd.html", name: 'DormAdminAddOrEdit', component: DormAdminAddOrEdit},
      {path: "/dormAdmins/toEdit/:id.html", name: 'DormAdminAddOrEdit', component: DormAdminAddOrEdit},

      {path: "/students.html", name: 'StudentsManager', component: StudentsManager},
      {path: "/students/toAdd.html", name: 'StudentsAddOrEdit', component: StudentsAddOrEdit},
      {path: "/students/toEdit/:id.html", name: 'StudentsAddOrEdit', component: StudentsAddOrEdit},

      {path: "/dorms.html", name: 'DormsManager', component: DormsManager},
      {path: "/dorms/toAdd.html", name: 'DormsAddOrEdit', component: DormsAddOrEdit},
      {path: "/dorms/toEdit/:id.html", name: 'DormsAddOrEdit', component: DormsAddOrEdit},

      {path: "/absences.html", name: 'AbsencesManager', component: AbsencesManager},
      {path: "/absences/toAdd.html", name: 'AbsencesAddOrEdit', component: AbsencesAddOrEdit},
      {path: "/absences/toEdit/:id.html", name: 'AbsencesAddOrEdit', component: AbsencesAddOrEdit},

      {path: "/modifyPassword.html", name: 'ModifyPassword', component: ModifyPassword}
    ]
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ '../views/About.vue')
  }
];

const router = new VueRouter({
  routes
});

export default router;
